﻿@*@model IEnumerable<ContosoUniversity.Models.Student>*@
@model PagedList.IPagedList<ContosoUniversity.Models.Student>
@using PagedList.Mvc;
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />

@{
    ViewBag.Title = "Students";
}

<h2>Students</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
@* 增加搜索框 *@
@using (Html.BeginForm("Index","Student", FormMethod.Get))
{
    <p>
        Find by name: @Html.TextBox("SearchString",ViewBag.CurrentFilter as string)
        <input type="submit" value="Search" />
    </p>
}

<!-- 将表格列标题增加排序的链接-->
<table class="table">
    <tr>
        <th>
            @*@Html.DisplayNameFor(model => model.LastName)*@
            @Html.ActionLink("LastName","Index",new { sortOrder=ViewBag.NameSortParm,currentFilter=ViewBag.CurrentFilter})
        </th>
        <th>
            @*@Html.DisplayNameFor(model => model.FirstMidName)*@FirstName
        </th>
        <th>
            @*@Html.DisplayNameFor(model => model.EnrollmentDate)*@
            @Html.ActionLink("EnrollmentDate","Index",new { sortOrder=ViewBag.DateSortParm, currentFilter = ViewBag.CurrentFilter})
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.LastName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FirstMidName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.EnrollmentDate)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.ID })
        </td>
    </tr>
}

</table>
<br/>
<!--增加页码元素-->
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action("Index",
    new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))


